<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    h4 {
      width: 400px;
      text-align: center;
    }
    td {
      width: 400px;
      height: 30px;
      text-align: center;
    }
  </style>
  <body>
    <h4>欢迎光临水果店</h4>
    <table border="1" id="app">
      <tr>
        <td><h5>苹果10￥/斤,折扣< 8折 ></h5></td>
      </tr>
      <tr>
        <td>请输入你要购买的斤数 <input type="text" v-model.number="msg" /></td>
      </tr>
      <tr>
        <td><button @click="count">结账购买</button></td>
      </tr>
      <tr>
        <td>
          结账单：总价{{sum}}￥元
          ；折后价：{{sum*0.8}}￥元；省了{{sum-sum*0.8}}￥元
        </td>
      </tr>
    </table>
    <script src="./vue.js"></script>

    <script>
      const app = new Vue({
        el: '#app',
        data: {
          msg: '',
          sum: 0,
        },
        methods: {
          count() {
            return (this.sum = this.msg * 10)
          },
        },
      })
    </script>
  </body>
</html>
